#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define EMPTY 0
#define OCCUPY 1
typedef int ElementType;
typedef struct HASHTABLE HashTable;
struct HASHTABLE{
	ElementType *elm;
	int *info;
	int size;
	int tableSize;
};

int NextPrime(int p);
HashTable *HashTableInit(int size);
_Bool InsertHashTable(HashTable*,ElementType);
int FindPos(HashTable*,ElementType);
int HashValue(HashTable*,ElementType);
int NextPrime(int p){
	if( 1 == p )return 2;
	do{
		int i;
		for(i=2;i*i<p;i++)
			if( 0 == (p%i) )
				break;
		if( i*i > p )
			break;
	}while( p++);
	return p;
}
HashTable *HashTableInit(int size){
	HashTable *h=malloc(sizeof(HashTable));
	h->size=0;
	h->tableSize=NextPrime(size);
	h->info=malloc(sizeof(int)*h->tableSize);
	memset(h->info,EMPTY,sizeof(int)*h->tableSize);
	h->elm=malloc(sizeof(ElementType)*h->tableSize);
	return h;
}
int HashValue(HashTable *h,ElementType key){
	return key%(h->tableSize);
}
_Bool InsertHashTable(HashTable *h,ElementType key){
	int currentPos=HashValue(h,key);
	int newPos=currentPos;
	int count=0;
	while( h->info[newPos] == OCCUPY && count <= (h->tableSize)/2 ){
		count++;
		newPos=(currentPos+count*count)%h->tableSize;
	}
	if( count <= (h->tableSize)/2 ){
		h->info[newPos]=OCCUPY;
		h->elm[newPos]=key;
		h->size++;
		return true;
	}else{
		return false;
	}
}
int FindPos(HashTable *h,ElementType key){
	int currentPos=HashValue(h,key);
	int newPos=currentPos;
	int count=0;
	while( h->info[newPos]==OCCUPY && h->elm[newPos] != key && count <= (h->tableSize/2) ){
		count++;
		newPos=(currentPos+count*count)%h->tableSize;
	}
	if( h->info[newPos] == EMPTY || count > (h->tableSize)/2 )
		return -1;
	else{
		return newPos;
	}
}

int main(void){
	int MSize,N;
	scanf("%d %d",&MSize,&N);
	int k[N];
	for(int i=0;i<N;i++)scanf("%d",&k[i]);
	HashTable *h=HashTableInit(MSize);
	for(int i=0;i<N;i++){
		InsertHashTable(h,k[i]);
	}
	int pos;
	_Bool firstChar=true;
	for(int i=0;i<N;i++){
		pos=FindPos(h,k[i]);
		if( firstChar ){
			firstChar=false;
			if( -1 == pos )
				printf("-");
			else
				printf("%d",pos);
		}else{
			if( -1 == pos )
				printf(" -");
			else
				printf(" %d",pos);
		}
	}
	return 0;
}
